<template>
	<view class='container bg-w'>
		<view class="header uni-flex uni-row flex-between">
			<uni-nav-bar title="巡查巡检详情">
				<template slot='left'>
					<view class="flex width-100">
						<i class='iconfont iconfanhui' @click='goBack()'></i>
					</view>
				</template>
			</uni-nav-bar>
		</view>
		<view class="main position-r-top">
			<view class="construction-data">
				<view class="form-list flex flex-between height-50 border-bottom">
					<text class="color-6 ">所属项目</text>
					<text class="color-6 ">{{listData.projectName}}</text>
				</view>
				<view class="form-list flex flex-between height-50 border-bottom">
					<text class="color-6 ">负责单位</text>
					<text class="color-6 ">{{listData.orgName}}</text>
				</view>
			</view>

			<view class="main" style="margin-top: 20px;">
				<uni-collapse :accordion="true">
					<uni-collapse-item v-for="(item,index) in listData.list" :key="index" :title="item.subProjectName" :open="true"
					 :showAnimation="true">
						<view class="uni-list">
							<view class="form-list flex flex-between height-50 border-bottom">
								<text class="color-6 ">巡检模板</text>
								<text class="color-6 ">{{item.inspectionName}}</text>
							</view>
							<view class="" v-for="(it,listIndex) in item.list" :key="listIndex">
								<view class="form-list flex flex-between height-50 border-bottom">
									<text class="color-6 ">{{it.subInspectionName}}</text>
									<text class="color-6 " :style="
                                        it.state == 0
                                            ? 'color:red'
                                            : 'color:#70DB55'
                                    ">{{it.state == 0 ?'异常':'通过'}}</text>
								</view>
								<view class="form-list border-bottom">
									<text class="color-6  height-50" style="color: grey;">{{!it.subInspectionRequirement?'暂无说明':it.subInspectionRequirement}}</text>
								</view>
							</view>

							<view class="form-list flex flex-between height-50 border-bottom">
								<text class="color-4 ">备注</text>
								<text class="color-8 " style="flex: 0.6; color: grey">{{!item.remarks ? '无': item.remarks}}</text>
							</view>

							<view class="form-list flex flex-between border-bottom">
								<view class="photograph flex flex-between" v-if="item.imgUrl.length">
									<view class="img_box" v-for="(imgItem,imgIndex) in item.imgUrl" :key="imgIndex">
										<image :src="imgItem" mode="" @click="previewImg(index,imgIndex)"></image>
									</view>
								</view>
								<view class="noImg" v-else>
									暂无图片
								</view>

							</view>

						</view>
					</uni-collapse-item>
				</uni-collapse>
			</view>

		</view>
	</view>
</template>

<script>
	import {
		getInspectionInfo,
		getFileById
	} from "@/common/api/Inspection.js"
	export default {
		data() {
			return {
				groupId: null,
				listData: [],
				imgUrlList: []
			}
		},
		onLoad(option) {
			this.groupId = option.groupId
			this.getData();
		},
		methods: {
			getData() {
				getInspectionInfo(this.groupId).then(res => {
					this.listData = res.data
					this.listData.list.forEach(item => {
						this.$set(item, 'imgUrl', []);
						var arr = item.attachmentId.split(",")
						arr.forEach(items => {
							if (items) {
								getFileById(items).then(r => {
									item.imgUrl.push('data:application/force-download;base64,' + uni.arrayBufferToBase64(r))
								})
							}
						})
					})
					console.log(this.listData)
				})
			},
			previewImg(index, imgIndex) {
				uni.previewImage({
					current: imgIndex,
					urls: this.listData.list[index].imgUrl
				});
			},

		}
	}
</script>

<style lang="less">
	.container {
		background-color: #F9F9F9;
	}

	.main {
		margin-top: 5rpx;
	}

	/deep/.container .header {
		border-bottom: none !important;
	}

	/deep/.uni-collapse .uni-list-cell {
		padding-left: 0 !important;
	}

	/deep/.uni-collapse-cell--open[data-v-8f47561c] {
		background-color: #fff;
	}

	/deep/.uni-collapse-cell__title-text[data-v-8f47561c] span {
		margin-left: 16rpx;
	}

	/deep/.uni-collapse-cell__title::before {
		content: " ";
		display: inline-block;
		position: absolute;
		left: 10rpx;
		width: 12rpx;
		height: 28rpx;
		border-radius: 3px;
		background-color: #09AAE9;
	}

	/deep/.uni-navbar--border[data-v-4afea59e] {
		border-bottom-width: 1px !important;
		border-bottom-style: solid !important;
		border-bottom-color: #fff !important;
	}

	.form-list {
		padding: 0 3%;
		background-color: #fff;
	}

	.img_box {
		padding: 10px 0;
		width: 48%;
	}

	/deep/.photograph {
		width: 100% !important;
	}

	/deep/uni-image {
		width: 100% !important;
		height: 220rpx;
	}

	uni-text[data-v-5e5edd1f] {
		color: #666;
	}

	text {
		overflow: hidden;
		text-overflow: ellipsis;
		white-space: nowrap;
	}

	/deep/.uni-collapse-cell[data-v-8f47561c] {
		border-color: #fff;
	}

	.screen-popup {
		background-color: #fff;
		min-height: 1000rpx;
		max-height: 1200rpx;

		.screen-popup-title {
			background-color: #f2f2f2;
			height: 100rpx;
			line-height: 100rpx;
			color: #666;

			>view {
				text {
					display: block;
					padding: 0 40rpx;
					line-height: 100rpx;
				}

				text:last-child {
					background-color: #09AAE9;
					color: #fff;
				}
			}
		}
	}

	.screen-popup-body {
		/deep/ .uni-searchbar__box {
			border-color: #eee
		}

		.uni-list {
			max-height: 980rpx;
			overflow-y: auto;

			uni-label {
				padding: 20rpx 3%;
			}
		}
	}
	
	.noImg {
		padding: 10px 10px;
		margin: auto;
		color: grey;
	}

	uni-input {
		height: 100rpx;
		line-height: 100rpx;
		margin-right: 20px;
		text-align: right;
		font-size: 28rpx;
		min-width: 60%;
		max-width: 80%;
	}
</style>
